package Week5.J0516;

import java.util.Scanner;

public class 游游的重组偶数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int q = scanner.nextInt();
        for (int i = 0; i < q; i++) {
            char[] num = scanner.next().toCharArray();
            System.out.println(change(num));
        }
    }

    private static String change(char[] num) {
        boolean flag = true;
        for (int i = num.length - 1; i >= 0; i--) {
            if ((num[i] - '0') % 2 == 0) {
                char tmp = num[i];
                num[i] = num[num.length - 1];
                num[num.length - 1] = tmp;
                flag = false;
                break;
            }
        }
        if (flag) {
            return "-1";
        }

        return new String(num);

//        int ret = 0;
//        double r = Math.pow(10, num.length - 1);
//
//        for (int i = 0; i < num.length; i++) {
//            ret += (int) ((num[i] - '0') * r);
//            r /= 10;
//        }
//        return ret;
    }
}
